package handlers

import (
	"github.com/gin-gonic/gin"
	"hj4/api/reponset"
	"hj4/api/request"
	"hj4/dao"
	"hj4/models"
)

func Add(c *gin.Context) {
	var data request.Add
	if err := c.ShouldBind(&data); err != nil {
		reponset.ResPonSetDataError(c, err.Error())
		return
	}
	video := models.Video{
		Title:   data.Title,
		FileUrl: data.FileUrl,
		Intro:   data.Intro,
	}
	err := dao.Add(&video)
	if err != nil {
		reponset.ResPonSetDataError(c, "添加失败")
		return
	}
	reponset.ResPonSetDataSuccess(c, "添加成功")
}
